unit FR_PrinterStatistic;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, JvExControls, JvLabel, ExtCtrls, JvExExtCtrls, JvImage,
  JvgProgress;

type
  TFR_Printer = class(TFrame)
    JvImagePImage: TJvImage;
    JvLPrinterName: TJvLabel;
    JvgProgress: TJvgProgress;
    TotalPages: TJvLabel;
    V_TotalPages: TJvLabel;
    Total: TJvLabel;
    V_Total: TJvLabel;

  private
    { Private declarations }
    function AddThousandSeparator(S: string; Chr: Char): string;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent; PrinterName: String; TotalPages, Total: integer);
  end;

implementation

{$R *.dfm}

constructor TFR_Printer.Create(AOwner: TComponent; PrinterName: String; TotalPages, Total: integer);
begin
  inherited Create(AOwner);
  JvLPrinterName.Caption:= PrinterName;
  V_TotalPages.Caption:= AddThousandSeparator(IntToStr(TotalPages), '.') + ' copias';
  V_Total.Caption:= AddThousandSeparator(IntToStr(Total), '.') + ' copias';
  JvgProgress.Percent:= Round(TotalPages*100/(Total));
  JvgProgress.Caption:= 'Porcentaje ['+FormatFloat(',0.00', TotalPages*100/(Total))+']';
end;

function TFR_Printer.AddThousandSeparator(S: string; Chr: Char): string;
var  
  I: Integer; 
begin 
  Result := S; 
  I := Length(S) - 2; 
  while I > 1 do
  begin 
    Insert(Chr, Result, I); 
    I := I - 3; 
  end; 
end; 


end.
